package com.wf.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wf.domain.LoanTargets;
import com.wf.domain.LoanTargetsES;
import com.wf.dto.LoanPageDTO;
import com.wf.repository.LoanRepository;
import com.wf.service.LoanTargetsService;
import com.wf.mapper.LoanTargetsMapper;
import com.wf.vo.LoanListVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
@Slf4j
public class LoanTargetsServiceImpl extends ServiceImpl<LoanTargetsMapper, LoanTargets>
    implements LoanTargetsService{

    @Autowired
    LoanTargetsMapper loanTargetsMapper;

    @Autowired
    LoanRepository loanRepository;
    @Override
    @Transactional
    public void pending(LoanTargetsES loanTargets) {
        LoanTargets targets = new LoanTargets();
        BeanUtils.copyProperties(loanTargets,targets);
        int flag = loanTargetsMapper.insert(targets);
        LoanTargetsES loanTargetsES = loanRepository.save(loanTargets);
        log.info("保存成功："+loanTargetsES);

    }

    @Override
    public List<LoanListVO> pageList(LoanPageDTO loanPageDTO) {

        Iterable<LoanTargetsES> targetsES = loanRepository.findAll();
        List<LoanTargetsES> byPurpose = loanRepository.findByPurpose("1");
        targetsES.forEach(
                item->{
                    log.info("item:"+item);
                }
        );
        return null;
    }
}




